﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Specialized;
using System.Net;

namespace BusinessLayer
{
    class LipkinFamilyMailer : IMailer
    {
        public void SendMail(System.Net.Mail.MailMessage message)
        {
            byte[] response;
            using (WebClient client = new WebClient())
            {
                response = client.UploadValues("http://lipkinfamily.com/sendEmail.php", new NameValueCollection()
                {
                    { "GUSER", "admin@yems.somee.com" },
                    { "GPWD" , "proWba6b" },
                    { "to", message.To.FirstOrDefault().Address},
                    { "subject", message.Subject},
                    { "body", message.Body}
                });
            }
            string sResponse = Encoding.ASCII.GetString(response);
            if (sResponse.Contains("FAIL"))
            {
                throw new Exception();
            }
        }
    }
}
